ultrasonic3 2.2.0
Loading...
Searching...
No Matches
ultrasonic3


Ultrasonic 3 Click

Ultrasonic 3 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Oct 2025.
  • Type : SPI type

Software Support

Example Description

This example demonstrates ranging with Ultrasonic 3 Click (Chirp/TDK time-of-flight). The example periodically triggers a measurement and prints the measured distance to the USB UART.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Ultrasonic3

Example Key Functions

Application Init

Initialize the USB UART logger and the Ultrasonic 3 driver, then apply the default configuration to start the sensor and prepare it for continuous single-shot ranging.

void application_init ( void )
{
log_cfg_t log_cfg;
ultrasonic3_cfg_t ultrasonic3_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ultrasonic3_cfg_setup( &ultrasonic3_cfg );
ULTRASONIC3_MAP_MIKROBUS( ultrasonic3_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == ultrasonic3_init( &ultrasonic3, &ultrasonic3_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ULTRASONIC3_ERROR == ultrasonic3_default_cfg ( &ultrasonic3 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define ULTRASONIC3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition ultrasonic3.h:105
void application_init(void)
Definition main.c:37
@ ULTRASONIC3_ERROR
Definition ultrasonic3.h:166

Application Task

Triggers a measurement and logs results (distance, sample number, and amplitude) every 100ms.

void application_task ( void )
{
Delay_ms ( 100 );
}
void application_task(void)
Definition main.c:73

Note

Make sure to configure falling-edge external interrupt on INT pin in bsp.c for your selected setup. Currently, only 3 interrupts are pre-configured for the following setups:

  • MCU Card for STM32 STM32F407ZG (MIKROBUS1)
  • MCU Card for Tiva TM4C129XNCZAD (MIKROBUS1)
  • MCU Card for PIC32 PIC32MX795F512L (MIKROBUS1)

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.